//
//  Equipment ViewController.m
//  OperationPro
//
//  Created by yaxue wang on 16/9/29.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "EquipmentViewController.h"
#import "TPKeyboardAvoidingScrollView.h"
#import "BankView.h"
#import "ScanViewController.h"
#import "ScreentoneViewController.h"
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
#import <BaiduMapAPI_Map/BMKMapComponent.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Map/BMKMapComponent.h>
#import <BaiduMapAPI_Location/BMKLocationComponent.h>
#import "SeekEquipmentViewController.h"
@interface EquipmentViewController()<UITextFieldDelegate,UIPickerViewDelegate,UIPickerViewDataSource,BMKMapViewDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate,UITextViewDelegate>
{
    NSInteger _eyeClick;
    NSInteger _selectClick;
    CTextField *_nameText;
    BankView *_bgView2;
    BMKLocationService* _locService;
    BMKGeoCodeSearch *_geocodesearch;
    BOOL isGeoSearch;
    double _longitude;
    double _latitude;
}
@property (nonatomic,assign) NSInteger addNum;
@property(nonatomic, assign)BOOL isProvince;
@property(nonatomic, strong)NSString *buiness;
@property(nonatomic, strong)NSString *type;
@property(nonatomic, strong)NSString *typeStr;
@property(nonatomic, strong)UILabel *typeLab;
@property(nonatomic, strong)UITextView *remarkView;
@property(nonatomic, strong)UILabel *screentoneLab;
@property(nonatomic, strong)TPKeyboardAvoidingScrollView *scrollView;
@property(nonatomic, strong)NSMutableArray *typeAr;
@property(nonatomic, strong)NSString*trame;
@property(nonatomic, strong)NSMutableArray*dataAr;
@property(nonatomic, strong)UIPickerView*pickerView2;
@property(nonatomic, strong)UIView *addView;
@end
@implementation EquipmentViewController
- (void)initView
{
    [super initView];
    //初始化BMKLocationService
    _locService = [[BMKLocationService alloc]init];
    _locService.delegate = self;
    //启动LocationService
    [_locService startUserLocationService];
    _geocodesearch = [[BMKGeoCodeSearch alloc] init];
    //编码服务的初始化(就是获取经纬度,或者获取地理位置服务)
    _geocodesearch.delegate = self;//设置代理为self
    _eyeClick =0;
    _selectClick=0;
    _dataAr=[[NSMutableArray alloc]init];
    _typeAr =[[NSMutableArray alloc]init];
    [self layoutView];
    [self.navBar setHidden:YES];
    self.navBar.leftView = nil;
    UIView *narView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 64)];
    narView.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:narView];
    
    UIView *backView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 64)];
    [narView addSubview:backView];
    [backView bk_whenTapped:^{
      [self backController];


    }];
    
    UIImage *icoBack = [UIImage imageNamed:@"Ico_nar_back"];
    UIImageView *imgBack = [[UIImageView alloc] initWithFrame:CGRectMake(15, 33, icoBack.size.width, icoBack.size.height)];
    imgBack.image=icoBack;
    [backView addSubview:imgBack];
    
    UILabel *backTitle = [[UILabel alloc] init];
    backTitle.frame=CGRectMake(CGRectGetMaxX(imgBack.frame) + 5, 20, 50 - imgBack.frame.size.width,44);
    
    [backTitle setText:@"返回"];
    [backTitle setTextColor:MainColor];
    [backTitle setFont:F(14)];
    [backView addSubview:backTitle];
    
    UILabel *titleLab =[[UILabel alloc]init];
    [narView addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(narView);
        make.top.equalTo(narView).offset(30);
    }];
    titleLab.font =F(16);
    titleLab.textColor =FontColor;
    titleLab.text=@"新增设备";
    UIImage *addImg =[UIImage imageNamed:@"Ico_detail_add"];
    UIView *addView=[[UIView alloc]initWithFrame:CGRectMake(WindowWidth-16-addImg.size.width, 34, addImg.size.width+16, addImg.size.height)];
    [narView addSubview:addView];
    UIImageView *addImageView=[[UIImageView alloc]initWithFrame:CGRectMake(0,0, addImg.size.width, addImg.size.height)];
    addImageView.image=addImg;
    [addView addSubview:addImageView];
    addImageView.userInteractionEnabled=YES;
    [addView bk_whenTapped:^{
        _addNum++;
        if (_addNum%2==0) {
            _addView.hidden=YES;
            
            
        }else
        {
            _addView.hidden=NO;
            
        }
        
    }];
    
    UIImage *addBg=[UIImage imageNamed:@"Ico_progressAddBG"];//@"Ico_home_scan",@"扫一扫",
    NSArray*nameAr=[NSArray arrayWithObjects:@"扫码",@"查找", nil];
    CGFloat imgWidth=70;
    
    _addView=[[UIView alloc]initWithFrame:CGRectMake(WindowWidth-imgWidth-15, 64+3,imgWidth, addBg.size.height+40*nameAr.count+5)];
    _addView.hidden=YES;
    _addView.backgroundColor=[UIColor clearColor];
    [self.view addSubview:_addView];
    UIImageView*addImgView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, imgWidth, 6)];
    addImgView.image=addBg;
    [_addView addSubview:addImgView];
    UIView *imgBgView=[[UIView alloc]initWithFrame:CGRectMake(0, addBg.size.height,imgWidth, 40*nameAr.count)];
    imgBgView.backgroundColor=MainColor;
    imgBgView.layer.cornerRadius=5;
    imgBgView.layer.masksToBounds=YES;
    [_addView addSubview:imgBgView];
    for (int i=0; i<nameAr.count; i++) {
        UIView *bgView=[[UIView alloc]initWithFrame:CGRectMake(0, 40*i, imgWidth, 40)];
        bgView.tag=1000+i;
        [imgBgView addSubview:bgView];
        UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(0, 0,imgWidth, 40)];
        lab.text=[NSString stringWithFormat:@"%@",[nameAr objectAtIndex:i]];
        [bgView addSubview:lab];
        lab.userInteractionEnabled=YES;
        lab.textColor=[UIColor whiteColor];
        lab.font=FF(15);
        lab.textAlignment=NSTextAlignmentCenter;
        UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(15, 40-0.5, imgBgView.bounds.size.width-15-7, 0.5)];
        line.backgroundColor=C(@"fd7d60");
        [bgView  addSubview:line];
        if (i==0){
#pragma mark 扫码
            
            [bgView bk_whenTapped:^{
                _addView.hidden=YES;
                //扫码
                ScanViewController *scanVC =[[ScanViewController alloc]init];
                [scanVC setDataType:HasListData];
                scanVC.orderUuid=self.orderUuid;
                scanVC.num=self.num;
                scanVC.instUuid=self.instUuid;
                [self pushController:scanVC Lever:1 Animated:YES];
                
                
                
            }];
        }else if (i==1){
#pragma mark 查找
            
            [bgView bk_whenTapped:^{
                _addView.hidden=YES;
                
                SeekEquipmentViewController *seekVC=[[SeekEquipmentViewController alloc]init];
                seekVC.orderUuid=self.orderUuid;
                seekVC.instUuid=self.instUuid;
                seekVC.num=self.num;
                [self pushController:seekVC Lever:1 Animated:YES];

                
            }];
        }
    }
   


    //请求设备类型
    [CClass HttpRequestTask:YES withUrl:@"select_showEquipSelect" withData:nil notifyError:YES onSuccess:^(BaseModel *model) {
         NSMutableArray* businessAr= [[NSMutableArray alloc] init];
        businessAr =[model.B_data objectForKey:@"business"];
       NSMutableArray*typeAllAr=[model.B_data objectForKey:@"type"];
        for (int i=0; i<businessAr.count; i++) {
            NSMutableDictionary *businessDic=[[NSMutableDictionary alloc]init];
           businessDic=[businessAr objectAtIndex:i];
          NSMutableArray *typeAr=[[NSMutableArray alloc]init];
            for (int j=0; j<typeAllAr.count; j++)
            {
                NSMutableDictionary *typeDic=[[NSMutableDictionary alloc]init];
                typeDic=[typeAllAr objectAtIndex:j];
                if ([[businessDic objectForKey:@"state"] isEqualToString:[typeDic objectForKey:@"bussiness"]])
                {
                    [typeAr addObject:typeDic];
                    
                }
            }
            
            [_dataAr addObject:@{@"business":businessDic,@"type":typeAr}];
 
        }
       [_pickerView2 reloadComponent:0];

    } onError:^(BaseModel *model) {
        
    }];
    

    __block typeof(self) blockself = self;

    _bgView2 =[[BankView alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, WindowHeight)witnOriginY:WindowHeight/3 withTitle:@"设备类型"];
    _bgView2.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:0.4];
    [self.view bringSubviewToFront:_bgView2];
    [self.view addSubview:_bgView2];
    _bgView2.hidden=YES;
    _pickerView2=[[UIPickerView alloc]initWithFrame:CGRectMake(0, 40, WindowWidth, WindowHeight/3-40)];
    _pickerView2.delegate=self;
    _pickerView2.dataSource=self;
    _pickerView2.backgroundColor =[UIColor whiteColor];
    _pickerView2.showsSelectionIndicator=YES;
    [_bgView2.whiteView addSubview:_pickerView2];
    [_bgView2 setSubmitBtnPress:^{
     int component0= [blockself.pickerView2 selectedRowInComponent:0];
        NSDictionary *dic =[blockself.dataAr objectAtIndex:component0];
        _buiness=[[dic objectForKey:@"business"] objectForKey:@"state"];
        
        int component1= [blockself.pickerView2 selectedRowInComponent:1];
        NSDictionary *typeDic =[blockself.typeAr objectAtIndex:component1];
        _typeStr=[typeDic objectForKey:@"desc"];
        _type=[typeDic objectForKey:@"state"];
        blockself.typeLab.textColor=[UIColor blackColor];
        blockself.typeLab.text=blockself.typeStr;

    }];
}
- (void)layoutView
{
    _scrollView =[[TPKeyboardAvoidingScrollView alloc]initWithFrame:CGRectMake(0, 64, WindowWidth, WindowHeight-64)];
    _scrollView.backgroundColor =BackColor;
    [self.view addSubview:_scrollView];
     [self.view bringSubviewToFront:_addView];
    UIColor *textColor = C(@"b9b7b7");
    if (WindowHeight==480) {
        _scrollView.contentSize=CGSizeMake(WindowWidth, WindowHeight+70);
    }
    
    
    for (int i=0; i<3; i++) {
        UILabel*lab=[[UILabel alloc]init];
        lab.frame =CGRectMake(25, 5+(39+48)*i, WindowWidth-25, 39);
        lab.font= F(14);
        lab.textColor=FontColor;
        [_scrollView addSubview:lab];
        NSArray *ar =[[NSArray alloc]initWithObjects:@"所属机构",@"设备类型",@"设备名称",nil];
        lab.text =[ar objectAtIndex:i];
        UIView *bgView =[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(lab.frame), WindowWidth, 48)];
        bgView.backgroundColor =[UIColor whiteColor];
        [_scrollView addSubview:bgView];
        UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 0.5)];
        line.backgroundColor =LineColor;
        [bgView addSubview:line];
        UILabel*line1=[[UILabel alloc]initWithFrame:CGRectMake(0, 47.5, WindowWidth, 0.5)];
        line1.backgroundColor =LineColor;
        [bgView addSubview:line1];
         if (i==0) {
             UIImage *image = [UIImage imageNamed:@"Ico_discuss_next"];
             UIButton *selectBtn =[UIButton buttonWithType:UIButtonTypeCustom];
             [bgView addSubview:selectBtn];
             selectBtn.frame =CGRectMake(0, 0.5, WindowWidth, 47);
             _screentoneLab=[[UILabel alloc]init];
             _screentoneLab.frame =CGRectMake(25, 0, WindowWidth-55-10-15-image.size.width, 47);
             _screentoneLab.font= F(12);
             _screentoneLab.text =@"请选择所属机构";
             _screentoneLab.textColor=textColor;
             [selectBtn addSubview:_screentoneLab];
             
             UIImageView *nextImgeView = [[UIImageView alloc] initWithFrame:CGRectMake(WindowWidth-15-image.size.width, (44-image.size.height)/2, image.size.width, image.size.height)];
             nextImgeView.image=image;
             [selectBtn addSubview:nextImgeView];
             
             [selectBtn bk_addEventHandler:^(id sender) {
                 ScreentoneViewController *screenVC=[[ScreentoneViewController alloc]init];
                 screenVC.backuiud=^(NSMutableDictionary*dic){
                     _screentoneLab.text =[dic objectForKey:@"name"];
                     _screentoneLab.textColor=[UIColor blackColor];
                     _trame =[dic objectForKey:@"uuid"];
                     
                 };
                 [self pushController:screenVC];
                 
             } forControlEvents:UIControlEventTouchUpInside];

             
        }else if(i==1){
                
                UIButton *selectBtn =[UIButton buttonWithType:UIButtonTypeCustom];
                [bgView addSubview:selectBtn];
                selectBtn.frame =CGRectMake(0, 0.5, WindowWidth, 47);
                _typeLab=[[UILabel alloc]init];
                _typeLab.frame =CGRectMake(25, 0, WindowWidth-55-10, 47);
                _typeLab.font= F(12);
                _typeLab.text =@"请选择设备类型";
                _typeLab.textColor=textColor;
                [selectBtn addSubview:_typeLab];
            
                [selectBtn bk_addEventHandler:^(id sender) {
                  
                [self.view endEditing:YES];
                _bgView2.hidden=NO;

                    int i = 0;
                    for (NSDictionary *dict in _dataAr) {
                        BOOL isBreak;
                        _typeAr=[dict objectForKey:@"type"];
                        [_pickerView2 reloadComponent:1];
                        for (int j=0; j<_typeAr.count; j++) {
                            NSDictionary *typeDic=[[NSDictionary alloc]init];
                            typeDic=[_typeAr objectAtIndex:j];
                            if ([[typeDic objectForKey:@"desc"] isEqualToString:_typeStr]) {

                                [_pickerView2 selectRow:i inComponent:0 animated:YES];
                                [_pickerView2 selectRow:j inComponent:1 animated:YES];
                                isBreak=YES;
                                break;
                            }

                        }
                        if (isBreak==YES) {
                            break;
                        }
                        i ++;
                    }
                    if (i == _dataAr.count) {
                        NSDictionary *dic =[_dataAr objectAtIndex:0];
                        _buiness=[[dic objectForKey:@"business"] objectForKey:@"state"];
                        _typeAr=[dic objectForKey:@"type"];
                       [_pickerView2 reloadComponent:1];
                        _typeStr=[[_typeAr objectAtIndex: 0] objectForKey:@"desc"];
                        _type=[[_typeAr objectAtIndex: 0] objectForKey:@"state"];
                    }

                        
                [UIView animateWithDuration:0.5 animations:^{
                    _bgView2.whiteView.frame=CGRectMake(0,WindowHeight/3*2 , WindowWidth, WindowHeight/3);
                } completion:nil];
                    
           
        } forControlEvents:UIControlEventTouchUpInside];       
        }else if (i==2) {
            _nameText =[[CTextField alloc]init];
            _nameText.font =F(12);
            [_nameText setMaxLength:10 LengthChangeBlock:nil];
            _nameText.tag =100+i;
            [bgView addSubview:_nameText];
            _nameText.frame =CGRectMake(25, 0.5, WindowWidth-50, 47);
            _nameText.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入设备名称" attributes:@{NSForegroundColorAttributeName: textColor}];
        }
        
        
    }
    UILabel*remarkLab=[[UILabel alloc]init];
    remarkLab.frame =CGRectMake(25, 5+(39+48)*3, WindowWidth-25, 39);
    remarkLab.font= F(14);
    [_scrollView addSubview:remarkLab];
    remarkLab.text =@"备注";
    UIView *bgView =[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(remarkLab.frame), WindowWidth, 100)];
    bgView.backgroundColor =[UIColor whiteColor];
    [_scrollView addSubview:bgView];
    UILabel*line=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, WindowWidth, 0.5)];
    line.backgroundColor =LineColor;
    [bgView addSubview:line];
    UILabel*line1=[[UILabel alloc]initWithFrame:CGRectMake(0, 100, WindowWidth, 0.5)];
    line1.backgroundColor =LineColor;
    [bgView addSubview:line1];

    _remarkView = [[UITextView alloc] initWithFrame:CGRectMake(25, 10, WindowWidth-50, 100-10)];
    [_remarkView setText:@"设备其他信息"];
    _remarkView.delegate=self;
    [_remarkView setTextColor:C(@"b9b7b7")];
    [_remarkView setFont:F(12)];
    [bgView addSubview:_remarkView];
    UIButton *agreeBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    agreeBtn.frame =CGRectMake(33,CGRectGetMaxY(bgView.frame)+20, WindowWidth-66, 35);
    [agreeBtn setBackgroundColor:MainColor];
    agreeBtn.layer.masksToBounds=YES;
    agreeBtn.layer.cornerRadius=8;
    [agreeBtn setTitle:@"确定" forState:UIControlStateNormal];
    agreeBtn.titleLabel.font =F(15);
    [agreeBtn bk_addEventHandler:^(id sender) {
       
    
                  //有报账单
            if ([_screentoneLab.text isEqualToString:@"请选择所属机构"]) {
                [CClass showMessage:@"请选择所属机构!"];
                return;
            }
            
            if ([_typeLab.text isEqualToString:@"请选择设备类型"]) {
                [CClass showMessage:@"请选择设备类型!"];
                return;
            }
            if (_nameText.text.length == 0) {
                [CClass showMessage:@"请输入设备名称!"];
                return ;
            }
       

        
            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
            [dic setObject:self.orderUuid forKey:@"orderUuid"];
            [dic setObject:_trame forKey:@"instUuid"];
            [dic setObject:_buiness forKey:@"bussines"];
            [dic setObject:_type forKey:@"typeCd"];
            [dic setObject:_nameText.text forKey:@"machineName"];
          if ([_remarkView.text isEqualToString:@""]||[_remarkView.text isEqualToString:@"设备其他信息"]) {
              [dic setObject:@"" forKey:@"remark"];

           }else
           {
               [dic setObject:_remarkView.text forKey:@"remark"];

           }
            [self setIsLoading:YES];
            [CClass HttpRequestTask:YES withUrl:@"machine_machineInput" withData:dic notifyError:YES onSuccess:^(BaseModel *model) {
                [CClass showLittleTimeMessage:@"添加成功" completion:^{
                    [self backController];
                    [self setIsLoading:NO];
                    
                    
                }];
                
            } onError:^(BaseModel *model) {
                [self setIsLoading:NO];

                
            }];
            
 
        
            
        

        
    } forControlEvents:UIControlEventTouchUpInside];
    [_scrollView addSubview:agreeBtn];
    
    
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
    
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 35;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if (component==0) {
        return _dataAr.count;
        
    }else
    {
        return _typeAr.count;
    }
}
-(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (component==0) {
        NSDictionary *dic =[_dataAr objectAtIndex:row];
        return [[dic objectForKey:@"business"] objectForKey:@"desc"];
    }else
    {
        NSDictionary *dic =[_typeAr objectAtIndex:row];
        return [dic objectForKey:@"desc"];
    }
    
    
    
    
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    if (component==0) {
        NSDictionary *dic =[_dataAr objectAtIndex:row];
        _buiness=[[dic objectForKey:@"business"] objectForKey:@"state"];
        _typeAr=[dic objectForKey:@"type"];
        [_pickerView2 reloadComponent:1];
        
        
    }else
    {

    }
    
    
    
}

#pragma mark 定位
/**
 *用户位置更新后，会调用此函数
 *@param userLocation 新的用户位置
 */
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
    //关闭地位
    
    
    [self onClickReverseGeocode];
    [_locService stopUserLocationService];
}
-(void)onClickReverseGeocode  //发送反编码请求的.
{
    isGeoSearch = false;
    CLLocationCoordinate2D pt = (CLLocationCoordinate2D){0, 0};//初始化
    if (_locService.userLocation.location.coordinate.longitude!= 0
        && _locService.userLocation.location.coordinate.latitude!= 0) {
        //如果还没有给pt赋值,那就将当前的经纬度赋值给pt
        pt = (CLLocationCoordinate2D){_locService.userLocation.location.coordinate.latitude,
            _locService.userLocation.location.coordinate.longitude
        };
    }
    BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];//初始化反编码请求
    reverseGeocodeSearchOption.reverseGeoPoint = pt;//设置反编码的店为pt
    BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];//发送反编码请求.并返回是否成功
    if(flag)
    {
        echo(@"反geo检索发送成功");
    }
    else
    {
        echo(@"反geo检索发送失败");
    }
}
-(void) onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{

    for (int i = 0; i < result.poiList.count; i++) {
        
        BMKPoiInfo* poi = [result.poiList objectAtIndex:i];
        if (i==0) {
            _latitude= poi.pt.latitude;
            _longitude = poi.pt.longitude;
            
#pragma mark 机构请求
            NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];
            [dic setObject:[NSNumber numberWithDouble:_longitude] forKey:@"longitude"];
            [dic setObject:[NSNumber numberWithDouble:_latitude] forKey:@"latitude"];
            [CClass HttpRequestTask:YES withUrl:@"select_showInstSelect" withData:dic notifyError:YES onSuccess:^(BaseModel *model) {
                NSMutableArray *ar=[model.B_data objectForKey:@"list"];
                NSDictionary *dic =[ar objectAtIndex:0];
                _trame=[dic objectForKey:@"uuid"];
                _screentoneLab.text=[dic objectForKey:@"name"];
                _screentoneLab.textColor=[UIColor blackColor];
                
            } onError:^(BaseModel *model) {
                
            }];
            
        }
    }
}
- (void)textViewDidChange:(UITextView *)textView{
    if ([CClass stringContainsEmoji:textView.text]) {
        textView.text=[textView.text substringToIndex:textView.text.length-2];
        return;
    }
    if (textView.markedTextRange == nil && textView.text.length > 200)  //加上 textView.markedTextRange == nil判断，当此属性为nil时，代表不在这种联想输入等待确定状态。
            
        {
            
            textView.text = [textView.text substringToIndex:200];
            
        }
   
}
- (void)textViewDidBeginEditing:(UITextView *)textView{
    if ([textView.text isEqualToString:@"设备其他信息"]) {
            [textView setText:@""];
            [textView setTextColor:[UIColor blackColor]];
        }
    
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    
    if ([[[UITextInputMode currentInputMode]primaryLanguage] isEqualToString:@"emoji"]) {
        return NO;
    }

    return YES;
    
}


@end
